package com.puboot.module.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.puboot.common.util.Pagination;
import com.puboot.module.admin.mapper.BizArticleMapper;
import com.puboot.module.admin.mapper.BizMessageMapper;
import com.puboot.module.admin.model.BizContact;
import com.puboot.module.admin.model.BizMessage;
import com.puboot.module.admin.service.BizMessageService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Service
@AllArgsConstructor
public class BizMessageServiceImpl extends ServiceImpl<BizMessageMapper, BizMessage> implements BizMessageService {

  private final BizMessageMapper bizMessageMapper;

    @Override
    public IPage<BizMessage> pageBizMessageAll(BizMessage bizMessage, Integer pageNumber, Integer pageSize) {
        IPage<BizMessage> page = new Pagination<>(pageNumber, pageSize);
        return page.setRecords(bizMessageMapper.selectAll(page, bizMessage));
    }

    @Override
    @CacheEvict(value = "bizMessage", allEntries = true)
    public int deleteBatch(Integer[] ids) {
        return bizMessageMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
